package com.peas.platform.common.core.exception;

import cn.hutool.core.util.StrUtil;
import com.peas.platform.common.core.constant.Constants;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class BaseException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private String code;
    private String message;
    private Throwable cause;

    public BaseException(String code, String message, Throwable cause) {
        this.code = code;
        this.message = message;
        this.cause = cause;
    }

    public BaseException(String code, String message) {
        this(code, message, null);
    }

    public BaseException(String message) {
        this(Constants.DEFAULT_ERROR_CODE, message);
    }

    public BaseException(String message, Throwable cause) {
        this(Constants.DEFAULT_ERROR_CODE, message, cause);
    }

    public BaseException(Throwable cause, String message, Object... args) {
        this(Constants.DEFAULT_ERROR_CODE, StrUtil.format(message, args), cause);
    }

    public BaseException() {
        this(Constants.DEFAULT_ERROR_MESSAGE);
    }

}
